Skip to content

Conversation

@kimfromsiberia
Copy link

No description provided.

Copy link

@lwof lwof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Несколько небольших улучшений.

}
names = ['Оля', 'Петя', 'Вася', 'Маша']
for name in names:
if is_male[name]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут можно чуть сократить код. Как минимум нам хотелось бы что бы осталась только одна f-строка, что бы избежать двойного редактирования.

Suggested change
if is_male[name]:
gender = 'мужской' if is_male[name] else 'женский'
print(f'{name} {gender}')

['Оля', 'Петя', 'Гриша'],
]
print(f'Всего {len(groups)} группы')
group_number = 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут вместо подсчета в переменной, лучше использовать enumerate, это более pythonic way. Плюс меньше ошибок, и другим разработчикам будет сразу понятно что мы просто последовательно все элементы нумеруем (а не что-то более хитрое)

Comment on lines 17 to 20
if student['first_name'] not in names:
names[student['first_name']] = 1
else:
names[student['first_name']] += 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как продвинутый вариант можно использовать get с аргументом по умолчанию 0:

Suggested change
if student['first_name'] not in names:
names[student['first_name']] = 1
else:
names[student['first_name']] += 1
names[student['first_name']] = names.get(student['first_name'], 0) + 1

import random
import uuid
import datetime
import pprint
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if __name__ == "__main__":
print(generate_chat_history())
messages = generate_chat_history()
# pprint.pprint(messages)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Старайся не забывать удалять закоментированый дебажный код.

# Вывести количество гласных букв в слове
word = 'Архангельск'
vowel_letters = 'аеёиоуыэюя'
counter = 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

было бы отлично использовать чуть более конкретные имена вроде vowel_counter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants